#ifndef PROTOCOLS_H
#define PROTOCOLS_H

#include "libs/core/model/presenter.h"
#include "serverliveinfo.h"
#include <QJsonDocument>

enum ResponseStatus { OK_RESPONSE_STATUS = 200 };

struct AddPresenterRequest
{
    static QString toJson(const yc::Presenter& presenter, const yc::LiveInfo& liveInfo)
    {
        const QJsonObject jo { { "presenter", presenter.toJsonObject() },
                               { "liveInfo",
                                 ServerLiveInfo::fromLiveInfo(liveInfo).toJsonObject() } };
        return QJsonDocument(jo).toJson(QJsonDocument::Compact);
    }
};

struct AddPresenterResponse
{
    yc::Presenter presenter;
    yc::LiveInfo live_info;

    static AddPresenterResponse fromJsonObject(const QJsonObject& jo)
    {
        return AddPresenterResponse {
            yc::Presenter { jo["presenter"].toObject() },
            ServerLiveInfo::fromJsonObject(jo["liveInfo"].toObject()).toLiveInfo()
        };
    }
};

#endif // PROTOCOLS_H
